from basic.device.Android import Android
from airtest.core.api import *

class headlinesPage(Android):

    # 市民头条
    newsBtn = "com.cloudbae.lovenanning:id/news_holder"
    # 新闻标题
    newsTitle = "com.cloudbae.lovenanning:id/tv_title"
    # 关闭提示登录
    close_LoginFrame = "com.cloudbae.lovenanning:id/realNameFrame_close"

    # 点击
    @classmethod
    def clickNews(self):
        sleep(4)
        closeHint = self.poco(self.close_LoginFrame)
        if closeHint.exists():
            closeHint.click()
        for i in range(2):
            swipe((613, 1102), (613, 90))
        sleep(1)
        self.poco(self.newsBtn).click()

    # 点击文明城市
    @classmethod
    def clickCivilize(self):
        self.poco(text="文明城市").click()

    # 点击时政
    @classmethod
    def clickNow(self):
        self.poco(text="时政").click()

    # 点击城市消息
    @classmethod
    def clickCity(self):
        self.poco(text="城市消息").click()

    # 文明城市列表
    @classmethod
    def getTitle(self):
        aa = self.poco(self.newsTitle)
        print(len(aa))
        listText = []
        for i in range(0, len(aa)):
            listText.append(aa[i].get_text())
        print("-------")
        print(listText)
        return listText



